/*
  This file is part of bnc.

  bnc is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  bnc is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with bnc.  If not, see <http://www.gnu.org/licenses/>.
*/
#include "./stack.h"
#include <string.h>

typedef struct
{
  unsigned int pLength, pPhase;
  char pLastByte;
  stack* pStack;
  node** pTree;
  node* pNode;
  char** pTable;
} compressor;

void compressorConstructor (compressor* aCompressor);
void compressorReadMatrix (compressor* aCompressor, unsigned char* aBufferI, unsigned int aLength);
unsigned int compresserBuildHeader (compressor* aCompressor, unsigned char* aBufferO);
void compressorBuildBinaryTree (compressor* aCompressor, node* aNode, unsigned char* aBufferO);
unsigned int compressorCompress (compressor* aCompressor, unsigned char* aBufferI, unsigned int aLength, unsigned char* aBufferO);
unsigned char compressorGetLastByte (compressor* aCompressor);
unsigned char compressorReadBit (compressor* aCompressor, char* aBufferI);
char compressorReadByte (compressor* aCompressor, char* aBufferI);
void compressorRecoverHeader (compressor* aCompressor, char* aBufferI);
unsigned int compressorDecompress (compressor* aCompressor, char* aBufferI, unsigned int aLength, char* aBufferO);
void compressorDestructor(compressor* aCompressor);
